package com.rms.hkpc.presenter;


import com.google.gson.reflect.TypeToken;
import com.rms.hkpc.apiresult.ApiResultData;
import com.rms.hkpc.constant.AllConstants;
import com.rms.hkpc.db.dto.InsightDto;
import com.rms.hkpc.model.InsightModel;
import com.rms.hkpc.model.listener.OnResultListener;
import com.rms.hkpc.util.SPUtil;
import com.rms.hkpc.view.IInsightView;

public class InsightPresenter extends BasePresenter<IInsightView> {
    private InsightModel insightModel = new InsightModel();

    public void getData() {
        insightModel.getData(SPUtil.getInstance().getString(AllConstants.PROJECT_ID), new OnResultListener() {
            @Override
            public void onSuccess(Object apiResult) {
                if (getView() != null) {
                    getView().onGetDataSuccess((ApiResultData<InsightDto>) apiResult);
                }
            }

            @Override
            public void onFails(Exception e) {
                if (getView() != null) {
                    getView().onGetDataFails(e);
                }
            }
        }, new TypeToken<ApiResultData<InsightDto>>() {
        }.getType());
    }
}
